<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateQuizzesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('quizzes', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name', 255);
            $table->tinyInteger('type');
            $table->text('options')->default(null);
            $table->integer('group_id', false, true);
            $table->integer('user_id', false, true);
            $table->boolean('is_public')->default(false);
            $table->integer('copper_limit')->default(0);
            $table->dateTime('stop_at');
            $table->tinyInteger('status')->default(2);
            $table->string('result', 255)->nullable();
            $table->timestamps();
            $table->foreign('group_id')->references('id')->on('groups');
            $table->foreign('user_id')->references('id')->on('users');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('quizzes');
    }
}
